//https://codeforces.com/problemset/problem/1177/B
//题意：把整数连接在一起，给出第n个数是多少
//模拟，个位单独讨论
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll num[20];
    num[0]=9;
    num[1]=9;
    for(int i=2;i<=12;i++){
        num[0]*=10;
        num[i]=num[i-1]+num[0]*i;
    }    
    ll n;
    scanf("%lld",&n);
    int k=1;
    num[0]=0;
    while(num[k]<=n) k++;
    ll temp=n-num[k-1];
    ll x=temp/k;
    ll y=temp%k;
    if(n<=9) printf("%lld",n);
    else if(temp==0){
        printf("9");
    }
    else{
        ll z=9;
        for(int i=1;i<k-1;i++){
            z*=10;
            z+=9;
        }
        z+=x;
        if(y==0){
            printf("%lld",z%10);
        }
        else{
            z+=1;
            for(int i=1;i<=k-y;i++){
                z/=10;
            }
            z%=10;
            printf("%lld",z);
        }
    }
    system("pause");
}